|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectmisc.ScoreKeeper<A>
A - key of the hashmap, for example a Value-objectpublic class ScoreKeeper<A>
Simple class which can be used to keep track of the score of a set of objects. An example of using this class is to count how many times a set of values has been offered by the opponent.
| Field Summary | |
|---|---|
protected java.util.Map<A,java.lang.Integer> |
m
Map of objects and their score |
protected int |
max
The highest score in the map |
protected int |
total
The sum of all scores in the map |
| Constructor Summary | |
|---|---|
ScoreKeeper()
Creates a ScoreKeeper object by initializing the hashmap. |
|
ScoreKeeper(ScoreKeeper<A> sk)
Clones the given scorekeeper-object. |
|
| Method Summary | |
|---|---|
int |
compare(A o1,
A o2)
Comparator to compare the score of two objects. |
java.util.Set<A> |
getElements()
Returns the objects from which the score is registered. |
int |
getMaxValue()
Returns the highest score in the map. |
double |
getNormalizedScore(A a)
Returns the normalized score of the given object. |
double |
getRelativeScore(A a)
Returns the relative score of a given object. |
int |
getScore(A a)
Returns the score of the given object. |
java.util.TreeMap<A,java.lang.Integer> |
getSortedCopy()
|
int |
getTotal()
Returns the sum of all scores. |
void |
score(A a)
Adds one to the score of the given object. |
void |
score(A a,
int score)
Method used to add a given score to a given object. |
java.lang.String |
toMathematicaListPlot()
Returns a Mathematica list plot of the map. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Comparator |
|---|
equals |
| Field Detail |
|---|
protected java.util.Map<A,java.lang.Integer> m
protected int max
protected int total
| Constructor Detail |
|---|
public ScoreKeeper()
public ScoreKeeper(ScoreKeeper<A> sk)
sk - object keeper which is cloned.| Method Detail |
|---|
public void score(A a)
a - object to which one must be added to its score.
public void score(A a,
int score)
a - object to which the given score must be added.score - to be added to the object.public int getScore(A a)
a - object from which the score must be returned.
public double getNormalizedScore(A a)
a - the object from which the score is requested.
public double getRelativeScore(A a)
a - object from which the score must be returned
public int compare(A o1,
A o2)
compare in interface java.util.Comparator<A>public java.lang.String toString()
toString in class java.lang.Objectpublic java.util.TreeMap<A,java.lang.Integer> getSortedCopy()
public int getMaxValue()
public int getTotal()
public java.util.Set<A> getElements()
public java.lang.String toMathematicaListPlot()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||